﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<CRM.Database.Model.TechnicRequestsExt>" %>
<%--<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<CRM.Models.TechnicRequestsExt>" %>--%>
<%@ Import Namespace="CRM.Resourses" %>

<%
    var profuctSystemsCol = new CRM.Database.Model.ProductSystemsCollection();
%>


<% Html.DevExpress().GridView(settings =>
                                    {
                                        settings.Name = "gdProductSystems";
                                        settings.KeyFieldName = "IdProductSystem";
                                        settings.CallbackRouteValues = new { Controller = "TD", Action = "TechnicRequestProductSystems", key = Model.Key };
                                        settings.SettingsPager.PageSize = 20;

                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.ProductSystem;
                                            column.FieldName = "ProductSystemNameLocalized";
                                            column.EditFormSettings.Visible = DefaultBoolean.False;
                                        });

                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.ProductMark;
                                            column.FieldName = "ProductMarkExt";
                                            column.EditFormSettings.Visible = DefaultBoolean.False;
                                        });

                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.ProductSystem;
                                            column.FieldName = "IdProductSystem";
                                            column.Visible = false;
                                            column.Width = 300;
                                            column.EditFormSettings.Visible = DefaultBoolean.True;
                                            column.ColumnType = MVCxGridViewColumnType.ComboBox;
                                            var comboBoxProperties = column.PropertiesEdit as ComboBoxProperties;
                                            if (comboBoxProperties != null)
                                            {
                                                comboBoxProperties.Width = 300;
                                                comboBoxProperties.DropDownStyle = DropDownStyle.DropDownList;
                                                comboBoxProperties.DataSource = profuctSystemsCol.GetProdustSystemsListByCustomerId(Model.Request.IdCustomer);
                                                //comboBoxProperties.DataSource = DB.GetProdustSystemsListByCustomerId(Model.Request.IdCustomer);
                                                comboBoxProperties.ValueField = "IdProductSystem";
                                                comboBoxProperties.ValueType = typeof(int);
                                                comboBoxProperties.Columns.Add("ProductSystemNameLocalized", Resourses.ProductSystem);
                                                comboBoxProperties.Columns.Add("ProductMarkExt", Resourses.ProductMark);
                                            }
                                        });

                                        settings.CommandColumn.Visible = true;
                                        settings.CommandColumn.NewButton.Visible = true;
                                        settings.CommandColumn.DeleteButton.Visible = true;
                                        settings.CommandColumn.EditButton.Visible = false;
                                        settings.SettingsBehavior.ConfirmDelete = true;
                                        settings.SettingsEditing.Mode = GridViewEditingMode.EditFormAndDisplayRow;
                                        settings.Width = 500;
                                        settings.SettingsEditing.AddNewRowRouteValues = new { Controller = "TD", Action = "TechnicRequestProductSystemsAdd", key = Model.Key };
                                        settings.SettingsEditing.DeleteRowRouteValues = new { Controller = "TD", Action = "TechnicRequestProductSystemsDelete", key = Model.Key };
                                    }).Bind(Model.ProdustSystemsList).GetHtml();
%>